/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ac.ui.controls;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;

/**
 *
 * @author empcl_000
 */
public class PCLTable extends JTable {

    public PCLTable() {
        DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
        rightRenderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT);
        setAutoCreateRowSorter(true);

        setModel(new javax.swing.table.DefaultTableModel(
                new Object[][]{
                    {null, null, null, null},},
                new String[]{
                    "Title 1"
                }
        ));

    }

    private String type;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getValue() {
        String returnData = "";
        int sel = this.getSelectedRow();
        if (sel != -1) {
            returnData = this.getValueAt(sel, 0).toString();
        }
        return returnData;

    }

    public String getValue(int num) {
        String returnData = "";
        int sel = this.getSelectedRow();
        if (sel != -1) {
            returnData = this.getValueAt(sel, num).toString();
        }
        return returnData;

    }

    public String getText() {
        String returnData = "";
        int sel = this.getSelectedRow();
        if (sel != -1) {
            returnData = this.getValueAt(sel, 1).toString();
        }
        return returnData;

    }

    public void clear() {

        DefaultTableModel dm = (DefaultTableModel) this.getModel();
        dm.getDataVector().removeAllElements();
        dm.fireTableDataChanged();
    }

}
